//
//  WebViewController.m
//  oc1
//
//  Created by kokuma on 2017/2/19.
//  Copyright © 2017年 kokumams. All rights reserved.
//WKWebView

#import "WebViewController.h"


@interface WebViewController ()
@property (readwrite, nonatomic, strong) NSString *url;
@end

@implementation WebViewController

- (instancetype)initWithUrl:(NSString *)url{
     self = [super init];
     if(url){
         _url=url;
     }
     return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    if(!_url){
        _url=@"http://www.cnblogs.com/mddblog/";
    }
    [self addWebView];
}

- (void)addWebView {
    // 1.创建webview，并设置大小，"20"为状态栏高度
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, self.view.frame.size.width-20, self.view.frame.size.height - 20)];
    // 2.创建请求
    NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:_url]];
    // 3.加载网页
    [webView loadRequest:request];
    
    // 最后将webView添加到界面
    [self.view addSubview:webView];
}

@end
